import React, { useState } from "react";
import Counter from "./counter";
import myContext from './createContext'

function Example() {
    const [count, setCount] = useState(0); // 数组结构

    return (
        <div>
            <p>You clicked {count} times</p>
            <button onClick={() => { setCount(count + 1) }}>click me</button>
            {/* 关键代码 */}
            <myContext.Provider value={count}>
                <Counter />
            </myContext.Provider>
        </div>
    )
}

export default Example;